using System;
using System.IO;
using System.Text;
using System.Diagnostics;
using System.Collections.Generic;

using Widgetsphere.Core.Logging;
using Widgetsphere.Core.Util;

namespace Widgetsphere.Core.Logging
{
	public partial class DefaultLogConfiguration : ILogConfiguration
	{
		private const string DefaultFileName = "Default.Widgetsphere.log";
		private const string DefaultFileLength = "5242880";
		private List<TraceListener> _listeners = null;
		#region ILogConfiguration Members
		public bool AutoFlush
		{
			get
			{
				return true;
			}
		}

		public TraceLevel GetTraceLevel(string switchName)
		{
			return TraceLevel.Verbose;
		}

		public int IndentSize
		{
			get
			{
				return 0;
			}
		}

		public event EventHandler LogConfigurationChanged;

		public List<TraceListener> TraceListeners
		{
			get
			{

				if (_listeners == null)
				{
					_listeners = new List<TraceListener>();
					//_listeners.Add(CreateDefaultListener());
				}
				return _listeners;
			}
		}

		//private TraceListener CreateDefaultListener()
		//{
		//  string inputData = StringHelper.EnsureDirectorySeperatorAtEnd(DirectoryHelper.GetWidgetsphereAppDirectory().FullName);
		//  inputData = inputData + DefaultFileName;//+"?" + DefaultFileLength;
		//  TraceListener mpftl = new TextWriterTraceListener(inputData);
		//  return mpftl;
		//}

		#endregion

    #region Dispose Stuff

    public void Dispose()
    {
      Dispose(true);
    }

    protected void Dispose(bool disposing) { }

    ~DefaultLogConfiguration()
    {
      Dispose(false);
    }

    #endregion

	}
}
